package com.ccys.cms.controller.corporateAndInsurance;

import com.ccys.cms.service.corporateAndInsurance.DeeplinkInsuranceService;
import com.ccys.common.vo.ResponseResult;
import com.ccys.db.dto.corporateAndInsurance.DeeplinkInsuranceDto;
import com.ccys.db.vo.corporateAndInsurance.DeeplinkInsuranceListSelectVo;
import com.ccys.db.vo.corporateAndInsurance.DeeplinkInsurancePageQueryVo;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 * @program: WhiteCoat
 * @description: 保险深度链接接口
 * @author: ZhangJingCan
 * @create: 2023-12-20 16:01
 **/

@RestController
@RequestMapping("corporateAndInsurance")
@Api(tags = "corporateAndInsurance 保险深度链接接口")
public class DeeplinkInsuranceController {

    @Autowired
    private DeeplinkInsuranceService deeplinkInsuranceService;


    @PostMapping("deeplinkInsurance")
    @ApiOperation("保存保险深度链接")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "对象id/修改必传", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "name", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "type", value = "0-DC,1-SUB", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "mobilePlatform", value = "0-IOS,1-Android", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "identifier", value = "identifier", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "status", value = "status", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "sessionTimeout", value = "sessionTimeout", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "timeoutWarning", value = "timeoutWarning", required = true, dataType = "string", paramType = "query"),
    })
    public ResponseResult saveDeeplinkInsurance(@ApiIgnore DeeplinkInsuranceDto dto) {
        return deeplinkInsuranceService.saveDeeplinkInsurance(dto);
    }

    @DeleteMapping("deeplinkInsurance")
    @ApiOperation("根据ID删除保险深度链接")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "对象id", required = true, dataType = "string", paramType = "query"),
    })
    public ResponseResult deleteDeeplinkInsurance(@ApiIgnore DeeplinkInsuranceDto dto) {
        return deeplinkInsuranceService.deleteDeeplinkInsurance(dto);
    }


    @GetMapping("deeplinkInsurance")
    @ApiOperation("分页查询保险深度链接")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "name模糊查询", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "identifier", value = "identifier模糊查询", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "mobilePlatform", value = "0-IOS,1-Android", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "type", value = "0-DC,1-SUB", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "status", value = "0/1,查询所有传null", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "startDate", value = "开始日期,格式:yyyy-MM-dd", required = false, dataType = "date", paramType = "query"),
            @ApiImplicitParam(name = "endDate", value = "结束日期,格式:yyyy-MM-dd", required = false, dataType = "date", paramType = "query"),
            @ApiImplicitParam(name = "orderByStr",
                    value = "(默认传：t1.created_on descend),(左到右依次:t1.name,t1.type,t1.mobile_platform,t1.identifier,t1.session_timeout,t1.status,t2.user_fullname,t1.created_on)",
                    required = true, dataType = "string", paramType = "query"),
    })
    public ResponseResult<PageInfo<DeeplinkInsurancePageQueryVo>, Object> findPageDeeplinkInsurance(@ApiIgnore DeeplinkInsuranceDto dto) {
        return deeplinkInsuranceService.findPageDeeplinkInsurance(dto);
    }


    @PutMapping("deeplinkInsurance/status")
    @ApiOperation("根据ID修改保险深度链接状态")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "对象id", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "status", value = "状态：0-禁用，1-启用", required = true, dataType = "string", paramType = "query"),
    })
    public ResponseResult updateDeeplinkInsuranceStatus(@ApiIgnore DeeplinkInsuranceDto dto) {
        return deeplinkInsuranceService.updateDeeplinkInsuranceStatus(dto);
    }

    @GetMapping("deeplinkInsurance/listSelect")
    @ApiOperation("查询深度链接下拉列表(只返回了id和name)")
    public ResponseResult<List<DeeplinkInsuranceListSelectVo>, Object> listSelect() {
        return deeplinkInsuranceService.listSelect();
    }

}
